#############################################################################
# ECOS.jl
# Wrapper around the ECOS solver https://github.com/ifa-ethz/ecos
# See http://github.com/JuliaOpt/ECOS.jl
#############################################################################
# test/direct.jl
# Test the direct interface for the ECOS.jl solver wrapper
#############################################################################

using Base.Test

# The values below are copied from data.h in ECOS source code
import ECOS

println(ECOS.ver())

function test1()
    n = 223
    m = 220
    p = 114
    l = 201
    ncones = 6

    c = [0.0, 0.0, 0.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

    h = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

    q = [3, 3, 3, 3, 3, 4]

    Gjc = [0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220]

    Gir = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219]

    Gpr = [-1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000]

    Ajc = [0, 111, 222, 322, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 539, 540, 541, 564, 565, 566, 589, 590, 591, 618, 619, 620, 632, 633, 634, 635, 636, 637, 638]

    Air = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 111, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 112, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 110, 113, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 3, 9, 15, 27, 53, 54, 57, 66, 67, 71, 74, 87, 92, 96, 98, 100, 101, 2, 8, 12, 19, 29, 30, 34, 37, 39, 42, 43, 44, 47, 50, 51, 56, 59, 70, 73, 79, 82, 85, 94, 102, 103, 0, 4, 7, 13, 14, 16, 17, 21, 23, 28, 31, 33, 36, 38, 60, 64, 78, 81, 88, 90, 91, 95, 99, 104, 105, 1, 6, 10, 20, 22, 26, 32, 35, 41, 46, 48, 49, 52, 55, 58, 65, 68, 69, 75, 76, 77, 80, 83, 84, 86, 93, 97, 106, 107, 5, 11, 18, 24, 25, 40, 45, 61, 62, 63, 72, 89, 108, 109, 110, 111, 112, 113]


    Apr = [-6.748099080141577400e-001, 9.587587238674218900e-001, -3.380262965696901900e-001, -6.289006455522118100e-001, 1.458932368908371500e+000, 8.103505672584934100e-001, -8.308676110497204000e-002, 2.638152658681099300e+000, 1.000625209233638700e+000, 1.443285740856571400e-001, 1.198960671699122800e+000, 8.042866751960948700e-001, -2.146877760548437900e-002, 1.252109754253975600e+000, 1.681372772953815700e+000, 1.160558110039982400e+000, 8.971595941547876300e-001, 9.934462168535226300e-001, 4.030425643552826300e-003, 4.520907269135507900e-001, 1.957531681292445900e+000, 8.367513704018149100e-001, -8.919073879004054700e-001, 1.364968014685880000e-001, -5.391443069926015200e-001, 1.218605709809697200e+000, 1.379628849398701500e+000, 7.705722581573115600e-002, -9.721580354507602900e-001, 1.341091680254979900e+000, 1.416856131617781900e+000, 1.367782802004573000e+000, 9.310015370881947700e-001, 1.025960903569425500e+000, 4.418055920652105800e-001, 1.797608571927105100e-001, -1.566236421056189400e+000, -1.293790728779894400e-001, -2.548793507296202000e-001, -1.327158583802827700e+000, 8.378869252146687900e-001, 9.208088134425553900e-001, 8.954835779157467300e-001, 1.872488747783192400e+000, 1.607749082930002300e-001, 1.703097419135647200e+000, 1.485966470102646500e+000, 1.950727391193988900e+000, 1.261282074772785800e+000, 2.116080672704367100e+000, 4.418819171779880300e-001, -6.070414095655145600e-001, 2.236741804227308500e-001, -1.390565074056968600e+000, -3.689063294445240100e-001, 6.275925564016111600e-001, 9.419119351808997700e-001, 2.051844704916749900e-002, -2.055013180419911200e+000, -8.138411920140069500e-001, -1.670986440999406000e+000, -4.312826132928389000e-001, -1.317178055102502500e-001, 4.129877571668971700e-002, -1.178000809237306800e-001, -5.094809536848188300e-002, 4.887140456297478000e-001, -6.048920026011540600e-001, -1.622657687025348600e+000, 9.468924561461561400e-002, -1.076752006167445400e+000, -4.544402225817885700e-001, -1.138681599263542200e+000, 6.297099350763062400e-001, 7.161553122227841700e-001, -2.326213079050594200e-001, -2.421425730439526200e-001, -3.527400894253913700e-001, -5.991000491511071500e-001, -4.501982881436522000e-001, -1.073527618321097300e+000, -1.837831580649836900e+000, -1.093506922417250900e+000, 3.123080272148109900e-002, 4.764624397863112500e-001, -9.744593174286131400e-001, -5.475935551016516400e-001, -1.185577848308040100e+000, -1.512429413719079500e+000, -8.503358079552569800e-001, -1.048119449917124500e+000, -2.950353712891531400e-001, 4.436355670528358600e-001, -1.976143927829304500e+000, -1.154872945269262400e-001, -8.267783537066453200e-001, -2.524533500828647400e-001, -2.934013148063512300e-001, -9.559308197633347200e-001, -5.099545278978906400e-001, 7.104569782287112300e-001, 2.586151051423653000e-001, 9.670875274511733200e-001, -1.580472136196336100e-001, 4.036019169202506600e-001, -4.419329075671284400e-001, 1.335760493316310000e-001, -2.443367984060260100e-001, 5.346171843774407700e-001, 9.240837092450902800e-002, 1.000000000000000000e+000, -7.627629774659758300e+000, -8.317906940770274800e+000, -7.063111046330970300e+000, -8.991213209598194900e+000, -7.132056801314573300e+000, -6.933147988332642300e+000, -8.002850393982971200e+000, -7.763929473153173600e+000, -7.316196508551362500e+000, -6.857489440772187800e+000, -6.933435917031895100e+000, -8.453055934420948600e+000, -7.746956878849250200e+000, -6.987480243537588000e+000, -6.898256465718047200e+000, -7.035033952525910900e+000, -7.332300809407010800e+000, -8.868148466875196000e+000, -7.895445920224761800e+000, -8.477688226774738200e+000, -6.724790281248850500e+000, -8.026080227654171400e+000, -8.247796522362861500e+000, -7.893131787368933100e+000, -7.953077643849715300e+000, -7.085517647070380700e+000, -7.757918623860442500e+000, -9.404980440162075800e+000, -9.111021916635516900e+000, -6.753547752596220200e+000, -6.208328120779675900e+000, -7.460712402671073400e+000, -8.051154905293161700e+000, -6.979795864345947000e+000, -7.285373299414776400e+000, -7.935549231771511300e+000, -7.333663096710840700e+000, -7.549354579130950400e+000, -7.125439770244579300e+000, -8.444455837718113100e+000, -7.607705936847165300e+000, -6.947711222611268100e+000, -7.559561213742542300e+000, -6.633232534378238100e+000, -7.285067573640397100e+000, -7.198034090285221800e+000, -8.301173708858458500e+000, -7.740676955875905200e+000, -8.389317110487786200e+000, -7.030503781850090800e+000, 7.483837125022816400e-001, 9.972172897309477000e-001, 8.635272324715717000e-001, 3.437357445286000600e-001, 1.356057545748600200e+000, 7.747994541454063000e-001, -5.029337660688439900e-001, 7.320209587792132500e-001, 9.007328043370961300e-001, 1.839182838430090300e+000, -1.352604803382542600e+000, 1.440339792882617200e+000, 5.409160633286138600e-001, -9.096356667070149000e-002, 2.145906552675194100e-001, 1.749366326171780000e+000, 1.710862586429138200e+000, 5.617170924142114200e-001, 8.075937970441778900e-001, 5.294053117812258500e-001, 8.007328881544743000e-001, 6.824506852180559600e-001, -4.466422007073587200e-001, 4.125165857556476500e-001, 1.264599468598445900e+000, 1.195482116831558800e+000, 5.815701470999368200e-001, 1.480145121963046200e+000, 1.228974130124139900e+000, -9.887375252743877400e-001, 4.957232610676656800e-001, 2.201242074660017000e-001, -8.949779589135298300e-002, 4.463714750361750200e-001, 1.104458211701637000e+000, 1.146057798756675600e+000, 1.607064328082671100e+000, -3.342540671866551800e-001, -3.733869343080511400e-001, 1.376984209826379600e+000, 1.134842638638303900e+000, 1.578816025652644900e+000, 8.631161307174450800e-003, 6.628552272325566300e-001, -4.235551988694613600e-001, -5.931434773175525700e-002, 1.107744286910284700e+000, 1.308043758809049000e+000, 1.474220016986390400e+000, 6.094036504382410700e-001, 2.586151051423653000e-001, 7.690092056142631100e-001, -1.580472136196336100e-001, 2.410499789745967300e-001, -4.419329075671284400e-001, 6.725262868347948700e-001, -2.443367984060260100e-001, 9.310955439202097700e-001, 9.240837092450902800e-002, 9.816510048711224500e-001, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -5.000000000000000000e-001, -5.000000000000000000e-001, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, 1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, 1.000000000000000000e+000, -1.000000000000000000e+000, -1.000000000000000000e+000, 1.000000000000000000e+000]

    b = [-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, -0.5]

    G = ECOS.ECOSMatrix(Gpr, Gjc, Gir)
    A = ECOS.ECOSMatrix(Apr, Ajc, Air)
    mywork = ECOS.setup(n, m, p, l, ncones, q, 0, G, A, c, h, b)

    exitflag = ECOS.solve(mywork)
    @show exitflag
    @test exitflag == ECOS.ECOS_OPTIMAL

    # Call after comparing values with correct values
    ECOS.cleanup(mywork, 0)
end
test1()

function test2()
    #= 
    Original problem:
    
    Max   x
    s.t.  x = 3
          8u + 9v <= 25
          -x + u + v = 0
          x free
          u <= 0
          v >= 0
    
    ECOS form:

    Min  -x
    s.t.  x           == 3
         -x +  u +  v == 0
              8u + 9v <= 25
               u      <= 0
                   -v <= 0
    =#

    n = 3
    m = 3
    p = 2
    l = 3
    ncones = 0
    q = Int[]
    G = [ 0  8  9;
          0  1  0;
          0  0 -1]
    A = [ 1  0  0;
         -1  1  1]
    c = [-1, 0, 0]
    h = [25, 0, 0]
    b = [ 3, 0]

    ecos_A = ECOS.ECOSMatrix(float(A))
    ecos_G = ECOS.ECOSMatrix(float(G))
    infeas_prob = ECOS.setup(n, m, p, l, ncones, q, 0,  ecos_G,
                                                        ecos_A,
                                                        float(c),
                                                        float(h),
                                                        float(b))

    exitflag = ECOS.solve(infeas_prob)
    @show exitflag
    @test exitflag == ECOS.ECOS_PINF

    ECOS.cleanup(infeas_prob, 0)
end
test2()
